package com.ruoyi.wechat.controller;

import com.ruoyi.wechat.domain.AppCoupon;
import com.ruoyi.wechat.domain.vo.AjaxResult;
import com.ruoyi.wechat.service.IAppCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.ruoyi.wechat.domain.vo.AjaxResult.success;

/**
 * 优惠券Controller
 *
 * @author YinHeng
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/coupon")
public class AppCouponController {
    @Autowired
    private IAppCouponService appCouponService;

    /**
     * 查询优惠券列表
     */
    @GetMapping("/list")
    public AjaxResult list(AppCoupon appCoupon) {
        List<AppCoupon> list = appCouponService.selectAppCouponList(appCoupon);
        return success(list);
    }

    /**
     * 获取优惠券详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(appCouponService.selectAppCouponById(id));
    }

}
